package com.dreamthen.service.impl;


import com.dreamthen.dao.IUserDao;
import com.dreamthen.entity.User;
import com.dreamthen.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author zengms
 * @Date 2023-10-22 10:29:15
 **/
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserDao userDao;

    @Override
    public void addUser(User user) {
        userDao.add(user);
        System.out.println("****添加成功****");
    }

    @Override
    public User getUser(String id) {
        return userDao.getUser(id);
    }

    @Override
    public void updateUser(User user) {
        userDao.updateUser(user);
        System.out.println("****修改成功****");
    }

    @Override
    public void delUser(String id) {
        userDao.delUser(id);
        System.out.println("*****删除成功*****");
    }

    @Transactional
    @Override
    public void dealData(User user) {
        userDao.updateUser(user);
        userDao.add(user);
    }
}
